# -*- encoding=utf8 -*-
"""
RedFlag-TC0000107  （拍摄进入装饰页）文字颜色及气泡互用功能
先使用颜色再使用气泡场景
清除气泡场景
先使用气泡再使用颜色场景
清除颜色场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *

auto_setup(__file__)
shooter = CameraVideoShooter()

case_text = "这是一条测试数据"
case_Text = "测试编辑文字功能"

log("--------------------------------先使用颜色再使用气泡场景--------------------------------------")
"""
拍摄视频进入装饰页
点击文字
输入文案
使用第三个字体
点击颜色
使用第三个颜色
点击气泡
使用第三个气泡
点击确定
断言
"""

shooter.enter_photography_decoration_page()
shooter.click_element(decoration_page_text_function)
shooter.input_text_in_element(decoration_page_text_function_input, case_text)
shooter.click_element(decoration_page_text_function_font[3])
shooter.click_element(decoration_page_text_function_colour)
shooter.click_element(decoration_page_text_function_choice_colour[3])
shooter.click_element(decoration_page_text_function_bubble)
shooter.click_element(decoration_page_text_function_choice_bubble[3])
shooter.click_element(decoration_page_text_function_confirm)
shooter.assert_image_exists(r"tpl1748571981115.png", "断言失败，预期图片并未出现", record_pos=(-0.004, -0.007), resolution=(1224, 2700))

log("--------------------------------清除气泡场景--------------------------------------")
"""
点击文字
点击编辑
点击气泡
点击清除
点击确定
断言
"""

touch((0.5,0.46))
shooter.click_element(decoration_page_text_editing_edit)
shooter.click_element(decoration_page_text_function_bubble)
shooter.click_element(decoration_page_text_function_choice_bubble[0])
shooter.click_element(decoration_page_text_function_confirm)
shooter.assert_image_exists(r"tpl1748572619498.png", "断言失败，预期图片并未出现", record_pos=(-0.001, -0.008), resolution=(1224, 2700))

log("--------------------------------先使用气泡再使用颜色场景--------------------------------------")
"""
点击文字
点击编辑
点击气泡
使用第六个气泡
点击颜色
使用第三个颜色
点击确认
断言
"""

touch((0.5,0.46))
shooter.click_element(decoration_page_text_editing_edit)
shooter.click_element(decoration_page_text_function_bubble)
shooter.click_element(decoration_page_text_function_choice_bubble[6])
shooter.click_element(decoration_page_text_function_colour)
shooter.click_element(decoration_page_text_function_choice_colour[2])
shooter.click_element(decoration_page_text_function_confirm)
shooter.assert_image_exists(r"tpl1748596071397.png", "断言失败，预期图片并未出现", record_pos=(0.002, 0.007), resolution=(1224, 2700))

log("--------------------------------清除颜色场景--------------------------------------")
"""
点击文字
点击编辑
点击颜色
点击清除按钮
点击确认
断言
"""
touch((0.5,0.46))
shooter.click_element(decoration_page_text_editing_edit)
shooter.click_element(decoration_page_text_function_colour)
shooter.click_element(decoration_page_text_function_choice_colour[0])
shooter.click_element(decoration_page_text_function_confirm)
shooter.assert_image_exists(r"tpl1748573723248.png", "断言失败，预期图片并未出现", record_pos=(0.006, 0.008), resolution=(1224, 2700), threshold=0.9)

# 关闭应用
stop_app(UGC_package_name)